
int data = 3;
int latch = 4;
int clock = 5;

void setup()
{
  pinMode(data, OUTPUT);
  pinMode(latch, OUTPUT);
  pinMode(clock, OUTPUT);
}

void loop()
{
  int delayTime = 150;  // delay 1/10 sec before each update
  int flashTime = 100;  // flash all the LEDs with 1/2 dec delay
  int value=0;          // this is the value written to the 595
  updateLEDs(0);
  for (int i=0; i<8; i++)
  {
    value = value | (1 << i);
    updateLEDs(value);
    delay(delayTime);
  }
  // Flash the LEDs to mimick full revs
  for (int j=0; j<4; j++)
  {
    updateLEDs(255);
    delay (flashTime);
    updateLEDs(0);
    delay (flashTime);
  }
}

void updateLEDs(int value)
{
  digitalWrite (latch, LOW);
  shiftOut(data, clock, MSBFIRST, value);
  digitalWrite (latch, HIGH);
}
